﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GeekShop.Properties;
using GeekShop.Tools;

namespace GeekShop
{
    partial class MainForm
    {
        #region Constructors
        private void InitializeMenuManager()
        {
            #region File Menu
            MenuParent fileItem = new MenuParent() { Text = "File" };
            MenuItem newItem = new MenuItem() { Text = "New", Image = Resources.document_new };
            MenuItem openItem = new MenuItem() { Text = "Open", Image = Resources.document_open, OnClick = new EventHandler(this.itemLoad_Click) };
            MenuItem saveItem = new MenuItem() { Text = "Save", Image = Resources.document_save };
            MenuItem saveAsItem = new MenuItem() { Text = "Save As", Image = Resources.document_save_as, OnClick = new EventHandler(this.itemSaveAs_Click) };
            MenuItem closeItem = new MenuItem() { Text = "Close", ShowAsToolBar = false };
            MenuItem seperatorItem1 = new MenuSeperator() { ShowAsToolBar = false };
            MenuItem exitItem = new MenuItem() { Text = "Exit", ShowAsToolBar = false };
            
            fileItem.Add(newItem);
            fileItem.Add(openItem);
            fileItem.Add(saveItem);
            fileItem.Add(saveAsItem);
            fileItem.Add(closeItem);
            fileItem.Add(seperatorItem1);           
            fileItem.Add(exitItem);
            #endregion

            #region Edit Menu
            MenuParent editItem = new MenuParent() { Text = "Edit" };
            MenuItem undoItem = new MenuItem() { Text = "Undo", Image = Resources.edit_undo, OnClick = new EventHandler(this.itemUndo_Click) };
            MenuItem redoItem = new MenuItem() { Text = "Redo", Image = Resources.edit_redo, OnClick = new EventHandler(this.itemRedo_Click) };
            MenuItem seperatorItem2 = new MenuSeperator();
            MenuItem cutItem = new MenuItem() { Text = "Cut", Image = Resources.edit_cut };
            MenuItem copyItem = new MenuItem() { Text = "Copy", Image = Resources.edit_copy };
            MenuItem pasteItem = new MenuItem() { Text = "Paste", Image = Resources.edit_paste };
            MenuItem deleteItem = new MenuItem() { Text = "Delete", Image = Resources.edit_delete };

            editItem.Add(undoItem);
            editItem.Add(redoItem);
            editItem.Add(seperatorItem2);
            editItem.Add(cutItem);
            editItem.Add(copyItem);
            editItem.Add(pasteItem);
            editItem.Add(deleteItem);
            #endregion

            #region Effects Menu
            this.toolManager = new ToolManager(this.pictureManager);
            MenuParent effectsItem = new MenuParent() { Text = "Effects" };
            foreach (ITool tool in this.toolManager.Tools)
            {
                MenuItem item = new MenuItem()
                {
                    Text = tool.Name,
                    Image = tool.Icon,
                    Tool = tool,
                    IsTool = true
                };
                item.ToolSelected += new ActiveToolChangedHandler(this.toolManager.activateTool);
                effectsItem.Add(item);
            }
            #endregion

            #region View menu
            MenuParent view = new MenuParent() { Text = "View" };
            MenuGroup arrangeForms = new MenuGroup() { Text = "Arrange Forms" };
            MenuItem cascadeItem = new MenuItem() { Text = "Cascade" , OnClick = new EventHandler(this.itemArrangeForms_Click), };
            MenuItem tileHorizontalItem = new MenuItem() { Text = "Tile Horizontal" , OnClick = new EventHandler(this.itemArrangeForms_Click) };
            MenuItem tileVertivalItem = new MenuItem() { Text = "Tile Vertical" , OnClick = new EventHandler(this.itemArrangeForms_Click) };
            
            view.Add(arrangeForms);
            arrangeForms.Add(cascadeItem);
            arrangeForms.Add(tileHorizontalItem);
            arrangeForms.Add(tileVertivalItem);

            this.MenuStrip.MdiWindowListItem = (ToolStripMenuItem)view.MenuItem;
            cascadeItem.ToolItem.Tag = MdiLayout.Cascade;
            cascadeItem.MenuItem.Tag = MdiLayout.Cascade;
            tileHorizontalItem.ToolItem.Tag = MdiLayout.TileHorizontal;
            tileHorizontalItem.MenuItem.Tag = MdiLayout.TileHorizontal;
            tileVertivalItem.ToolItem.Tag = MdiLayout.TileVertical;
            tileVertivalItem.MenuItem.Tag = MdiLayout.TileVertical;
            #endregion

            this.Add(fileItem);
            this.Add(editItem);
            this.Add(effectsItem);
            this.Add(view);
        }
        #endregion
    }
}
